/**
 * @author zhoutao
 *  2010-11-6
 */
package com.jlt.tag;


import javax.servlet.jsp.JspException;

import org.apache.commons.lang.StringUtils;

import com.jlt.service.sys.SysParamManager;

/**
 * @author zhoutao
 * 
 */
public class SysParamTag extends BaseTag {

	private static final long serialVersionUID = 1L;

	private String sysParamCode;
	private String sysParamTypeCode;
	private boolean outPutToJsp;
	private SysParamManager sysParamManager;

	@Override
	public int doEndTag() throws JspException {
		return super.doEndTag();
	}

	@Override
	public int doStartTag() throws JspException {
		sysParamManager = (SysParamManager) getManagerBean("sysParamManager");
		Object obj;
		if (StringUtils.isNotBlank(sysParamTypeCode)) {
			obj = sysParamManager.findSysParamByType(sysParamTypeCode);
		} else {
			obj = sysParamManager.getSysParamByCode(sysParamCode);
		}
		
		if(outPutToJsp){
			writeValue2Jsp(obj);
		}else{
			saveValues2PageContext(obj);
		}
		return SKIP_BODY;
	}

	public String getSysParamCode() {
		return sysParamCode;
	}

	public String getSysParamTypeCode() {
		return sysParamTypeCode;
	}

	public void setSysParamCode(String sysParamCode) {
		this.sysParamCode = sysParamCode;
	}

	public void setSysParamTypeCode(String sysParamTypeCode) {
		this.sysParamTypeCode = sysParamTypeCode;
	}

	public boolean getOutPutToJsp() {
		return outPutToJsp;
	}

	public void setOutPutToJsp(boolean outPutToJsp) {
		this.outPutToJsp = outPutToJsp;
	}
}
